<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: AutomataParser::Parser</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">AutomataParser::Parser</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../files/lib/automata_parser/parser_rb.html">
                lib/automata_parser/parser.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                Object
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000008">add_rule</a>&nbsp;&nbsp;
      <a href="#M000009">del_rule</a>&nbsp;&nbsp;
      <a href="#M000003">new</a>&nbsp;&nbsp;
      <a href="#M000004">parse</a>&nbsp;&nbsp;
      <a href="#M000007">tag_end</a>&nbsp;&nbsp;
      <a href="#M000005">tag_start</a>&nbsp;&nbsp;
      <a href="#M000006">text</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->
    <div id="includes">
      <h3 class="section-bar">Included Modules</h3>

      <div id="includes-list">
        <span class="include-name">REXML::StreamListener</span>
      </div>
    </div>

    <div id="section">





    <div id="attribute-list">
      <h3 class="section-bar">Attributes</h3>

      <div class="name-list">
        <table>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">current_state</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        </table>
      </div>
    </div>
      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000003" class="method-detail">
        <a name="M000003"></a>

        <div class="method-heading">
          <a href="#M000003" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(mapping,initial_state,caller)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000003-source">
<pre>
    <span class="ruby-comment cmt"># File lib/automata_parser/parser.rb, line 27</span>
27:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">mapping</span>,<span class="ruby-identifier">initial_state</span>,<span class="ruby-identifier">caller</span>)
28:       <span class="ruby-ivar">@graph</span> = <span class="ruby-constant">DirectedGraph</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">mapping</span>)
29:       <span class="ruby-ivar">@stack</span> = <span class="ruby-constant">Stack</span>.<span class="ruby-identifier">new</span>
30:       <span class="ruby-ivar">@current_state</span> = <span class="ruby-identifier">initial_state</span>
31:       <span class="ruby-ivar">@caller</span> = <span class="ruby-identifier">caller</span>
32:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000008" class="method-detail">
        <a name="M000008"></a>

        <div class="method-heading">
          <a href="#M000008" class="method-signature">
          <span class="method-name">add_rule</span><span class="method-args">(rule)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000008-source">
<pre>
    <span class="ruby-comment cmt"># File lib/automata_parser/parser.rb, line 88</span>
88:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_rule</span> <span class="ruby-identifier">rule</span>
89:       <span class="ruby-ivar">@graph</span>.<span class="ruby-identifier">add_arc</span>(<span class="ruby-identifier">rule</span>)
90:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000009" class="method-detail">
        <a name="M000009"></a>

        <div class="method-heading">
          <a href="#M000009" class="method-signature">
          <span class="method-name">del_rule</span><span class="method-args">(rule)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000009-source">
<pre>
    <span class="ruby-comment cmt"># File lib/automata_parser/parser.rb, line 92</span>
92:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">del_rule</span> <span class="ruby-identifier">rule</span>
93:       <span class="ruby-ivar">@graph</span>.<span class="ruby-identifier">del_arc</span>(<span class="ruby-identifier">rule</span>)
94:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000004" class="method-detail">
        <a name="M000004"></a>

        <div class="method-heading">
          <a href="#M000004" class="method-signature">
          <span class="method-name">parse</span><span class="method-args">(stream)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000004-source">
<pre>
    <span class="ruby-comment cmt"># File lib/automata_parser/parser.rb, line 34</span>
34:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse</span>(<span class="ruby-identifier">stream</span>)
35:       <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">parse_stream</span>(<span class="ruby-identifier">stream</span>, <span class="ruby-keyword kw">self</span>)
36:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000007" class="method-detail">
        <a name="M000007"></a>

        <div class="method-heading">
          <a href="#M000007" class="method-signature">
          <span class="method-name">tag_end</span><span class="method-args">(name)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000007-source">
<pre>
    <span class="ruby-comment cmt"># File lib/automata_parser/parser.rb, line 70</span>
70:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">tag_end</span>(<span class="ruby-identifier">name</span>)
71:       <span class="ruby-identifier">dst</span> = <span class="ruby-ivar">@graph</span>.<span class="ruby-identifier">walk_from</span>(<span class="ruby-ivar">@current_state</span>).<span class="ruby-identifier">with</span>(<span class="ruby-value str">&quot;/&quot;</span><span class="ruby-operator">+</span><span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>)
72:       <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">dst!</span>=<span class="ruby-keyword kw">nil</span>)
73:         <span class="ruby-identifier">tmp</span> = <span class="ruby-ivar">@stack</span>.<span class="ruby-identifier">pop</span>
74:         <span class="ruby-ivar">@current_state</span> = <span class="ruby-identifier">dst</span>
75: <span class="ruby-comment cmt">#        puts &quot;PARSED:#{name} -&gt; #{dst}&quot;</span>
76:         <span class="ruby-keyword kw">begin</span>
77:           <span class="ruby-identifier">eval</span> <span class="ruby-value str">&quot;             @caller.parsed_\#{name}(tmp)\n&quot;</span>
78:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">ex</span>
79: <span class="ruby-comment cmt">#          puts ex.message</span>
80: <span class="ruby-comment cmt">#          puts ex.backtrace.join(&quot;\n&quot;)</span>
81:         <span class="ruby-keyword kw">end</span>
82:       <span class="ruby-keyword kw">end</span>
83:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000005" class="method-detail">
        <a name="M000005"></a>

        <div class="method-heading">
          <a href="#M000005" class="method-signature">
          <span class="method-name">tag_start</span><span class="method-args">(name,attrs)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000005-source">
<pre>
    <span class="ruby-comment cmt"># File lib/automata_parser/parser.rb, line 38</span>
38:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">tag_start</span>(<span class="ruby-identifier">name</span>,<span class="ruby-identifier">attrs</span>)
39:       <span class="ruby-identifier">dst</span> = <span class="ruby-ivar">@graph</span>.<span class="ruby-identifier">walk_from</span>(<span class="ruby-ivar">@current_state</span>).<span class="ruby-identifier">with</span>(<span class="ruby-identifier">name</span>)
40:       <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">dst!</span>=<span class="ruby-keyword kw">nil</span>)
41:         <span class="ruby-identifier">tmp</span> = <span class="ruby-constant">ParserNode</span>.<span class="ruby-identifier">new</span>
42:         <span class="ruby-identifier">tmp</span>.<span class="ruby-identifier">name</span> = <span class="ruby-identifier">dst</span>
43:         <span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">each_pair</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>,<span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
44:           <span class="ruby-identifier">tmp</span>.<span class="ruby-identifier">values</span>[<span class="ruby-identifier">key</span>]=<span class="ruby-identifier">value</span>
45:         <span class="ruby-keyword kw">end</span>
46:         <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@stack</span>.<span class="ruby-identifier">empty?</span>
47:           <span class="ruby-ivar">@stack</span>.<span class="ruby-identifier">top</span>.<span class="ruby-identifier">link</span> <span class="ruby-identifier">tmp</span>
48:         <span class="ruby-keyword kw">end</span>
49:         <span class="ruby-ivar">@stack</span>.<span class="ruby-identifier">push</span> <span class="ruby-identifier">tmp</span>
50: 
51:         <span class="ruby-ivar">@current_state</span> = <span class="ruby-identifier">dst</span>
52: 
53: <span class="ruby-comment cmt">#        puts &quot;Found #{name} -&gt; #{dst}&quot;</span>
54:         <span class="ruby-keyword kw">begin</span>
55:           <span class="ruby-identifier">eval</span> <span class="ruby-value str">&quot;            @caller.found_\#{name}(tmp)\n&quot;</span>
56:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">ex</span>
57:         <span class="ruby-keyword kw">end</span>
58:       <span class="ruby-keyword kw">end</span>
59:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000006" class="method-detail">
        <a name="M000006"></a>

        <div class="method-heading">
          <a href="#M000006" class="method-signature">
          <span class="method-name">text</span><span class="method-args">(text)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000006-source">
<pre>
    <span class="ruby-comment cmt"># File lib/automata_parser/parser.rb, line 64</span>
64:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">text</span>(<span class="ruby-identifier">text</span>)
65:       <span class="ruby-keyword kw">if</span>(<span class="ruby-ivar">@stack</span>.<span class="ruby-identifier">top</span>)
66:         <span class="ruby-ivar">@stack</span>.<span class="ruby-identifier">top</span>.<span class="ruby-identifier">text</span> = <span class="ruby-identifier">text</span>
67:       <span class="ruby-keyword kw">end</span>
68:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>